package cn.zhoushengdao.eyeprotector

import android.content.Context
import android.content.Intent
import android.util.Log
import androidx.work.Worker
import androidx.work.WorkerParameters


class ServiceStarterWorker(context: Context, params: WorkerParameters) : Worker(context, params) {
    override fun doWork(): Result {
        Log.d("EyeProtector", "ServiceStarterWorker doWork")
        val serviceIntent = Intent(applicationContext, EyeProtectorService::class.java).apply {
            action = "SHOW_OVERLAY_IF_NECESSARY"
        }
        applicationContext.startForegroundService(serviceIntent)
        Log.d("EyeProtector", "ServiceStarterWorker doWork startForegroundService")
        return Result.success()
    }
}